/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Damian
 */
@Entity
@Table(name = "local_comment")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LocalComment.findAll", query = "SELECT l FROM LocalComment l"),
    @NamedQuery(name = "LocalComment.findByIdLocalComment", query = "SELECT l FROM LocalComment l WHERE l.localCommentPK.idLocalComment = :idLocalComment"),
    @NamedQuery(name = "LocalComment.findByIdLocal", query = "SELECT l FROM LocalComment l WHERE l.localCommentPK.idLocal = :idLocal"),
    @NamedQuery(name = "LocalComment.findByIdClient", query = "SELECT l FROM LocalComment l WHERE l.localCommentPK.idClient = :idClient"),
    @NamedQuery(name = "LocalComment.findByComment", query = "SELECT l FROM LocalComment l WHERE l.comment = :comment")})
public class LocalComment implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected LocalCommentPK localCommentPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 250)
    @Column(name = "COMMENT")
    private String comment;
    @JoinColumn(name = "ID_LOCAL", referencedColumnName = "ID_LOCAL", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Local local;
    @JoinColumn(name = "ID_CLIENT", referencedColumnName = "ID_CLIENT", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Client client;

    public LocalComment() {
    }

    public LocalComment(LocalCommentPK localCommentPK) {
        this.localCommentPK = localCommentPK;
    }

    public LocalComment(LocalCommentPK localCommentPK, String comment) {
        this.localCommentPK = localCommentPK;
        this.comment = comment;
    }

    public LocalComment(int idLocalComment, int idLocal, int idClient) {
        this.localCommentPK = new LocalCommentPK(idLocalComment, idLocal, idClient);
    }

    public LocalCommentPK getLocalCommentPK() {
        return localCommentPK;
    }

    public void setLocalCommentPK(LocalCommentPK localCommentPK) {
        this.localCommentPK = localCommentPK;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Local getLocal() {
        return local;
    }

    public void setLocal(Local local) {
        this.local = local;
    }

    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (localCommentPK != null ? localCommentPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LocalComment)) {
            return false;
        }
        LocalComment other = (LocalComment) object;
        if ((this.localCommentPK == null && other.localCommentPK != null) || (this.localCommentPK != null && !this.localCommentPK.equals(other.localCommentPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.LocalComment[ localCommentPK=" + localCommentPK + " ]";
    }
    
}
